package com.nwpu.controller;

import com.nwpu.common.Result;
import com.nwpu.domain.User;
import com.nwpu.service.UserService;
import com.nwpu.service.impl.JwtAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author DPH
 * @date 2023/5/22
 */
@RestController
@RequestMapping
public class LoginController {

    @Autowired
    private JwtAuthService jwtAuthService;

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result<String> login(@RequestBody User user) {
        String token = jwtAuthService.login(user.getUserId(), user.getPassword());
        return Result.of(token);
    }
}
